{% extends "base.html" %}
{# Copyright The IETF Trust 2021, All Rights Reserved #}
{% load origin %}
{% load static %}
{% load django_bootstrap5 %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static 'ietf/css/select2.css' %}">
{% endblock %}
{% block title %}Edit authors for {{ titletext }}{% endblock %}
{% block content %}
    {% origin %}
    <h1>
        Edit authors
        <br>
        <small class="text-body-secondary">{{ titletext }}</small>
    </h1>
    <form enctype="multipart/form-data" method="post" id="authors-form">
        {% csrf_token %}
        {% bootstrap_form change_basis_form %}
        <button id="add-author-button"
                type="button"
                class="btn btn-primary my-3"
                onclick="local_js.add_author()">
            Add new author
        </button>
        {% bootstrap_form formset.management_form %}
        <div id="authors-list">
            {% for form in formset %}
                <div class="card author-panel mb-3">
                    <div role="button" class="handle card-header">
                        <i class="bi bi-list"></i>
                    </div>
                    <div class="card-body draggable">
                        <div class="form-horizontal">{% bootstrap_form form layout='horizontal' %}</div>
                    </div>
                </div>
            {% endfor %}
        </div>
        <div id="empty-author-form" class="template d-none">
            <div class="card  author-panel mb-3">
                <div role="button" class="handle card-header">
                    <i class="bi bi-list"></i>
                </div>
                <div class="card-body draggable">
                    <div class="form-horizontal">{% bootstrap_form formset.empty_form layout='horizontal' %}</div>
                </div>
            </div>
        </div>
        <button type="submit" class="btn btn-primary">Submit</button>
        <a class="btn btn-secondary float-end"
           href="{% url "ietf.doc.views_doc.document_main" name=doc.name %}">
            Back
        </a>
    </form>
{% endblock %}
{% block js %}
    <script src="{% static 'ietf/js/sortable.js' %}"></script>
    <script src="{% static 'ietf/js/select2.js' %}"></script>
    <script>var ajax_url = '{% url "ietf.person.ajax.person_email_json" personid="123454321" %}';</script>
    <script src="{% static 'ietf/js/edit_authors.js' %}"></script>
{% endblock %}